<template>
  <div class="login">
    <div>邮&nbsp;&nbsp;箱：<el-input v-model="Email" type="text" class="input" placeholder="input Email"></el-input></div>
    <div>密&nbsp;&nbsp;码：<el-input v-model="password" type="text" class="input" placeholder="input password"></el-input></div>
    <div><el-button v-on:click="reLogin()" class="btn" type="success" plain>登录</el-button></div>
    <div><el-link type="danger" class="link" v-on:click="turnReister()">还没注册？点击注册</el-link></div>
  </div>
</template>

<script>
export default {
  name: "login",
  data() {
    return {
      Email: '',
      password: ''
    }
  },
  methods: {
    turnReister() {
      this.$router.push('/register')
    },
    reLogin() {
      axios.get("http://localhost:8181//login?email=" + this.Email + "&password=" + this.password).then((t) => {
        console.log(t);
        const userid = t.data;
        console.log(userid)
        // console.log(userid !== 0)
        if (userid !== 0) {
          this.$store.commit('getUid',userid)
          console.log(this.$store.state.uid)
          console.log(111)
          this.$router.push('/home')
        } else {
          this.$router.push('/login')
        }
      })

    }
  }
}
</script>

<style scoped>
  .login {
    position: absolute;
    top: 30%;
    left: 35%;
    right: 35%;
    /*border: 1px black solid;*/
    box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
    padding: 20px 40px;
  }

  .input {
    /*width: 80%;*/
    /*margin-top: 20px;*/
    /*margin-left: 10px;*/
    /*margin-right: 10px;*/
    /*margin-bottom: 10px;*/
  }

  .el-input {
    width: 80%;
    margin-top: 10px;
    margin-bottom: 15px;
  }

  .btn {
    width: 100px;
    height: 40px;
    margin-bottom: 10px;
    font-size: 18px;
  }

  .link{
    font-size: 20px;
  }
</style>